const CHARS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split(
    ''
)

class Util{
    /**
     * 生成UUID
     * @param { string } prefix 
     * @returns UUID值
     */
    static uuid(prefix = 'U') {
        let uid = [];
        uid[8] = uid[13] = uid[18] = uid[23] = '-';
        uid[14] = '4';
        let r;
        for (let i = 0; i < 36; i++) {
        if (!uid[i]) {
            r = 0 | (Math.random() * 16);
            uid[i] = CHARS[i === 19 ? (r & 0x3) | 0x8 : r];
        }
        }
        return prefix + '-' + uid.join('');
    }
}

export default Util